--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit eed3efe66a050a7645b4d55505c0a99079f46f7b
Parents : 43944b7
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-06-04T03:17:45+02:00
Updated recipe
Changes
2 files changed, 79 insertions(+), 10 deletions(-)
Diff
diff --git a/recipes/codec2/__init__.py b/recipes/codec2/__init__.py
index 5a651f38..11ad5fd7 100644
--- a/recipes/codec2/__init__.py
+++ b/recipes/codec2/__init__.py
@@ -1,3 +1,4 @@
+from os.path import join
from pythonforandroid.recipe import Recipe
from pythonforandroid.toolchain import current_directory, shprint
import sh
@@ -7,12 +8,27 @@ import sh
class Codec2Recipe(Recipe):
url = "https://github.com/markqvist/codec2/archive/00e01c9d72d3b1607e165c71c4c9c942d277dfac.tar.gz"
- built_libraries = {'libcodec2.so': 'build_linux/src'}
+ built_libraries = {'libcodec2.so': 'build_android/src'}
+
+ def include_flags(self, arch):
+ '''Returns a string with the include folders'''
+ codec2_includes = join(self.get_build_dir(arch.arch), 'build_android')
+ return (' -I' + codec2_includes)
+
+ def link_dirs_flags(self, arch):
+ '''Returns a string with the appropriate `-L<lib directory>` to link
+ with the libs. This string is usually added to the environment
+ variable `LDFLAGS`'''
+ return ' -L' + self.get_build_dir(arch.arch)
+
+ # def link_libs_flags(self):
+ # '''Returns a string with the appropriate `-l<lib>` flags to link with
+ # the libs. This string is usually added to the environment
+ # variable `LIBS`'''
+ # return ' -lcodec2{version} -lssl{version}'.format(version=self.version)
def build_arch(self, arch):
with current_directory(self.get_build_dir(arch.arch)):
- from rich.pretty import pprint
- import time
env = self.get_recipe_env(arch)
flags = [
"..",
@@ -20,17 +36,14 @@ class Codec2Recipe(Recipe):
"--fresh",
"-DCMAKE_BUILD_TYPE=Release",
]
- mkdir = sh.mkdir("-p", "build_linux")
- cd = sh.cd("build_linux")
- cmake = sh.Command('cmake')
- pprint(arch.command_prefix)
- pprint(env)
- pprint(flags)
- time.sleep(6)
+ mkdir = sh.mkdir("-p", "build_android")
+ cd = sh.cd("build_android")
+ cmake = sh.Command('cmake')
shprint(cmake, *flags, _env=env)
shprint(sh.make, _env=env)
+ sh.cp("../src/codec2.h", "./codec2/")
recipe = Codec2Recipe()
diff --git a/recipes/pycodec2/__init__.py b/recipes/pycodec2/__init__.py
new file mode 100644
index 00000000..df11c3e6
--- /dev/null
+++ b/recipes/pycodec2/__init__.py
@@ -0,0 +1,56 @@
+from pythonforandroid.recipe import CythonRecipe, IncludedFilesBehaviour
+from pythonforandroid.toolchain import current_directory, shprint
+from os.path import join
+import sh
+
+# class PyCodec2Recipe(IncludedFilesBehaviour, CythonRecipe):
+class PyCodec2Recipe(CythonRecipe):
+ url = "https://github.com/markqvist/pycodec2/archive/refs/heads/main.zip"
+ # src_filename = "../../../pycodec2"
+ depends = ["setuptools", "numpy", "Cython", "codec2"]
+ call_hostpython_via_targetpython = False
+
+ def get_recipe_env(self, arch, with_flags_in_cc=True):
+ """
+ Adds codec2 recipe to include and library path.
+ """
+ env = super().get_recipe_env(arch, with_flags_in_cc)
+
+ codec2_recipe = self.get_recipe('codec2', self.ctx)
+ env['CFLAGS'] += codec2_recipe.include_flags(arch) +" -l:libcodec2.so"
+ env['LDFLAGS'] += ' -L{}'.format(self.ctx.get_libs_dir(arch.arch))
+ env['LDFLAGS'] += ' -L{}'.format(self.ctx.libs_dir)
+ env['LDFLAGS'] += codec2_recipe.link_dirs_flags(arch)
+
+ return env
+
+ def build_arch(self, arch):
+ super().build_arch(arch)
+ with current_directory(self.get_build_dir(arch.arch)):
+ print(arch.arch)
+ print(arch)
+ shprint(sh.Command("pwd"))
+ shprint(sh.Command("ls"))
+
+ # pe_args = ["--replace-needed", "libcodec2.so.1.2", "libcodec2.so", "build/lib.linux-x86_64-3.11/pycodec2/pycodec2.cpython-311-x86_64-linux-gnu.so"]
+ # shprint(sh.Command("patchelf"), *pe_args)
+
+ # pe_args = ["--replace-needed", "libcodec2.so.1.2", "libcodec2.so", f"../../../../python-installs/sideband/{arch.arch}/pycodec2/pycodec2.cpython-311-x86_64-linux-gnu.so"]
+ # shprint(sh.Command("patchelf"), *pe_args)
+
+ # ../../../../python-installs/sideband/armeabi-v7a/pycodec2/pycodec2.cpython-311-x86_64-linux-gnu.so
+ # sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/pycodec2/armeabi-v7a__ndk_target_24/pycodec2/build/lib.linux-x86_64-3.11/pycodec2/pycodec2.cpython-311-x86_64-linux-gnu.so
+ # sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/sideband/armeabi-v7a/pycodec2/pycodec2.cpython-311-x86_64-linux-gnu.so
+ # print("=========================")
+ # input()
+
+
+ def postbuild_arch(self, arch):
+ super().postbuild_arch(arch)
+
+recipe = PyCodec2Recipe()
+
+# patchelf --replace-needed libcodec2.so.1.2 libcodec2.so sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/sideband/_python_bundle__arm64-v8a/_python_bundle/site-packages/pycodec2/pycodec2.so
+# patchelf --replace-needed libcodec2.so.1.2 libcodec2.so sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/sideband/_python_bundle__armeabi-v7a/_python_bundle/site-packages/pycodec2/pycodec2.so
+
+# patchelf --replace-needed libcodec2.so.1.2 libcodec2.so sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/sideband/_python_bundle__arm64-v8a/_python_bundle/site-packages/pycodec2/pycodec2.so; patchelf --replace-needed libcodec2.so.1.2 libcodec2.so sbapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/sideband/_python_bundle__armeabi-v7a/_python_bundle/site-packages/pycodec2/pycodec2.so
\ No newline at end of file
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────